#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int p, n, x, count = 0;
    scanf("%d   %d", &n, &x);
    for (int i = 1;i <= n;i++) {
        int t = i;
        while (t != 0) {
            p = t % 10;
            if (p == x)
                count++;
            t = t / 10;
        }

    }
    printf("%d", count);
    return 0;
}